#include <bits/stdc++.h>

using namespace std;

#define int long long

template<typename T> inline void read(T &x){
	T s = 0, f = 1; char ch = getchar();
	while(!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = getchar();
	while(isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
	x = s * f;
}

template<typename T, typename ...A> inline void read(T x, A ...a){
	read(x); read(a...);
}

typedef long long ll;

const int N = 1e5 + 10;
int n, m, l, v, v_0, ans;
int last;
int p[N];
int cnt;
struct node{
	int d, v, a;
} c[N];
int s[N][2];
int a[N][2];
int x[N * 10], cntx;

int pp[25];

bool check(int sum, int mark){
	int ss = 0, scnt = 0;
	memset(pp, 0, sizeof pp);
	for(int i = 1;i <= m;i ++){
		if(mark & (1 << i)){
			pp[++ ss] = p[i];
		}
	}
	for(int i = 1;i <= cnt;i ++){
		int k = lower_bound(pp + 1, pp + ss + 1, a[i][0]) - pp;
		if(k <= sum && pp[k] <= a[i][1]) scnt ++;
	}
	return (cnt == scnt);
}
bool vis[(1 << 21) + 10];

void dfs(int sum, int mark){
	if(sum >= ans) return ;
	if(vis[mark]) return ;
	vis[mark] = true;
	if(check(sum, mark)){
		ans = min(ans, sum);
		return ;
	}
	for(int i = 1;i <= m;i ++){
		dfs(sum + 1, mark | (1 << i));
	}
}

void work(){
	memset(p, 0, sizeof p);
	v_0 = cnt = cntx = 0;
	read(n), read(m), read(l), read(v);
	ans = m;
	for(int i = 1;i <= n;i ++){
		s[i][0] = s[i][1] = -1;
		read(c[i].d), read(c[i].v), read(c[i].a);
		if(c[i].a >= 0) v_0 ++;
		if(c[i].a == 0){
			if(c[i].v > v) s[i][0] = c[i].d, s[i][1] = l;
		} else if(c[i].a > 0){
			if(c[i].v > v){
				s[i][0] = c[i].d, s[i][1] = l;
				continue ;
			}
			int x = (v * v - c[i].v * c[i].v) / (2 * c[i].a) + 1;
			if(c[i].d + x <= l){
				s[i][0] = c[i].d + x;
				s[i][1] = l;
			}
		} else {
			if(c[i].v <= v) continue ;
			int x = ceil((v * v - c[i].v * c[i].v) * 1.0 / (2 * c[i].a)) - 1;
			s[i][0] = c[i].d;
			s[i][1] = min(l, c[i].d + x);
		}
	}
	for(int i = 1;i <= m;i ++){
		read(p[i]);
		x[++ cntx] = p[i];
	}
	for(int i = 1;i <= n;i ++){
		if(s[i][0] == -1) continue ;
		int k = lower_bound(p + 1, p + m + 1, s[i][0]) - p;
		if(k <= m && p[k] <= s[i][1]){
			cnt ++;
			a[cnt][0] = s[i][0], a[cnt][1] = s[i][1];
		}
	}
	cout << cnt << ' ';
	if(cnt == 0){
		cout << m << endl;
		return ;
	}
	if(v_0 == n){
		cout << m - 1 << endl;
		return ;
	}
	if(cnt <= 20 && m <= 20){
		memset(vis, false, sizeof vis);
		dfs(0, 0);
		cout << m - ans << endl;
	}
}

signed main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	srand(time(0));
	int T; read(T);
	while(T --) work();
	return 0;
}
